{extend name="common/base" /}
{block name="toindex"}
{/block}
{block name="body"}

{/block}
{block name="script"}


<script type="text/javascript">
    function onBridgeReady() {
        var data = {$data};
        var order_type = "{$order_type}";
        WeixinJSBridge.invoke(
                'getBrandWCPayRequest', data,
                function (res) {
                    if (res.err_msg == "get_brand_wcpay_request:ok") {
                        if (order_type == '2') {
                            window.location.href = "{:url('My/index')}";
                        } else {
                            window.location.href = "{:url('My/order')}";
                        }

                    } else {
//                            alert(res.err_code + res.err_desc + res.err_msg); // 显示错误信息
                        mui.alert('支付失败！', '提示', '确定', function () {
                            window.location.href = "{:url('My/index')}";
                        });
                    }
                }
        );
    }

    if (typeof WeixinJSBridge == "undefined") {
        if (document.addEventListener) {
            document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false);
        } else if (document.attachEvent) {
            document.attachEvent('WeixinJSBridgeReady', onBridgeReady);
            document.attachEvent('onWeixinJSBridgeReady', onBridgeReady);
        }
    } else {
        onBridgeReady();
    }
</script>
{/block}